package J5_24;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class test {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) {
            int n = in.nextInt();
            int res = 2;
            while (res * 2 <= n) {
                res *= 2;
            }
            System.out.println(res - 1);
        }

    }


    static int n;
    static int m;
    static boolean[] choose = new boolean[11];
    static int sum = 0;
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        dfs(1);
    }

    private static void dfs(int i) {
        if (sum == m) {
            for (int j = 1; j < choose.length; j++) {
                if (choose[j]) {
                    System.out.print(j + " ");
                }
            }
            System.out.println();
            return;
        }
        if (sum > m || i > n) return;
        sum += i;
        choose[i] = true;
        dfs(i + 1);
        choose[i] = false;
        sum -= i;
        dfs(i + 1);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str1 = in.next();
        String str2 = in.next();
        int len1 = str1.length();
        int len2 = str2.length();
        int[][] dp = new int[len1+1][len2+1];
        for (int i = 1; i <= len1; i++) {
            dp[i][0] = i;
        }
        for (int i = 1; i <= len2; i++) {
            dp[0][i] = i;
        }
        for (int i = 1; i <= len1; i++) {
            for (int j = 1; j <= len2; j++) {
                if (str1.charAt(i-1) == str2.charAt(j-1)) {
                    dp[i][j] = dp[i-1][j-1];
                }else {
                    dp[i][j] = Math.min(Math.min(dp[i-1][j-1] + 1,dp[i-1][j] + 1), dp[i][j-1] + 1);
                }
            }
        }
        System.out.println(dp[len1][len2]);
    }
}
